package com.hly.aidldemo;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;

import androidx.activity.ComponentActivity;
import androidx.annotation.Nullable;

import java.io.File;

public class MainActivity extends ComponentActivity {

    private final ServiceConnection mServiceConnection = new ServiceConnection() {
        @Override
        public void onServiceConnected(ComponentName name, IBinder service) {
            Information information = Information.Stub.asInterface(service);
            try {
                //传递参数
                information.basicTypes(18,18L,true,18.88f,18.88,"HI");
                information.Infor("张三丰",180);
                //获取参数
                Log.d("******isActive", String.valueOf(information.isActive()));
                Log.d("******getList", String.valueOf(information.getList()));
            } catch (RemoteException e) {
                throw new RuntimeException(e);
            }
        }

        @Override
        public void onServiceDisconnected(ComponentName name) {
            Log.d("******onServiceDisconnected,","onServiceDisconnected:"+name);
        }
    };

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main_activity_layout);

        Intent intent = new Intent(this,InforService.class);
        bindService(intent,mServiceConnection, Context.BIND_AUTO_CREATE);
    }
}
